<html>
<script src="images/jQuery.js"></script>
<script type="text/javascript">
	localStorage.version=4.1;
	if (!localStorage.beatCount) {
		localStorage.beatCount = 0
	}
	if (!localStorage.isAgreed) {
		localStorage.isAgreed = 0
	}
	if (!localStorage.mode) {
		localStorage.mode = "beat";
	}
	if (!localStorage.beatCountEnabled) {
		localStorage.beatCountEnabled = 1;
	}
	if (!localStorage.avatarURL || localStorage.avatarURL == "") {
		localStorage.avatarURL = 'images/icon_128.png';
	}
	if (!localStorage.isNotificationActivated) {
		localStorage.isNotificationActivated = '1';
	}

	var timer;
	var face_dir = localStorage.faceDir;

	function setBadageCount(count) {
		if (Number(localStorage.beatCountEnabled) == 0 || !count) {
			chrome.browserAction.setBadgeText({text:""});
		} else {
			localStorage.beatCount = count;
			chrome.browserAction.setBadgeText({text:count.toString()});
		}
		$('#beatCount').html(count);
	}
	function beat() {
		localStorage.beatCount++;
		setBadageCount(localStorage.beatCount);
		if (face_dir == "l") {
			chrome.browserAction.setIcon({path:"images/icon_19_h.png"});
			localStorage.faceDir = face_dir = "h";
		} else {
			chrome.browserAction.setIcon({path:"images/icon_19_l.png"});
			localStorage.faceDir = face_dir = "l";
		}
	}

	function ooxx() {
		localStorage.beatCount++;
		setBadageCount(localStorage.beatCount);
		if (face_dir == "j") {
			chrome.browserAction.setIcon({path:"images/icon_19_k.png"});
			localStorage.faceDir = face_dir = "k";
		} else {
			chrome.browserAction.setIcon({path:"images/icon_19_j.png"});
			localStorage.faceDir = face_dir = "j";
		}
	}

	// Create a simple text notification:
	var notification = webkitNotifications.createNotification(
			'images/icon_48.png', // icon url - can be relative
			'beatWife updated v'+localStorage.version, // notification title
			chrome.i18n.getMessage("notificationBody")  // notification body text
			);

	// Then show the notification.

	if (JSON.parse(localStorage.isNotificationActivated) < localStorage.version) {
		localStorage.isNotificationActivated = localStorage.version;
		notification.show();
		timer = window.setTimeout(function() {
			notification.cancel();
		}, 30000);
	}

/*chrome.extension.onRequestExternal.addListener(function(any request, MessageSender sender, function sendResponse) {...});
chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
    var url = last.pop();
    if (url) chrome.tabs.create({url: url});
 });*/
</script>
</html>
